<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets">

	<!-- 
		Replace path to template, title, header and body
		with actual data.
	 -->
	<ui:composition template="/template/template.xhtml">
        <ui:define name="pageTitle">Registro de Fabricante</ui:define>
        <ui:define name="pageHeader">Fabricante</ui:define>
        <ui:define name="body">
                <h1>Cadastro de Fabricantes</h1>
                <h:form id="edicao">

                        <h:messages />
                        <h:inputHidden value="#{fabricanteBean.fabricante.fabricante}" />


                        <h:panelGrid columns="2">
                                <h:outputLabel value="Nome:" />
                                <h:inputText id="nomeFabricante"
                                        value="#{fabricanteBean.fabricante.nome}" />

                                <h:outputLabel value="CNPJ:" />
                                <h:inputText id="CNPJFabricante"
                                        value="#{fabricanteBean.fabricante.CNPJ}" />

                                <h:outputLabel value="Insc Estadual:" />
                                <h:inputText id="InscEstadualFabricante"
                                        value="#{fabricanteBean.fabricante.inscricaoEstadual}" />

                                
                        </h:panelGrid>

                        <h:commandButton value="Salvar" action="#{fabricanteBean.salvar}" />
                        <h:commandButton value="Novo Fabricante"
                                action="#{fabricanteBean.novo}" />
                </h:form>

                <h:messages />
                <h:form id="lista">

                        <h:dataTable value="#{fabricanteBean.lista}" var="fabricane"
                                rules="rows" cellpadding="5">
                                <f:facet name="header">Listagem dos Fabricantes</f:facet>
                                <f:facet name="footer">Final da Listagem</f:facet>
                                <h:column>
                                        <f:facet name="header">Estado</f:facet>
                                        <h:commandLink action="#{fabricanteBean.ativar}">
                                                <h:graphicImage library="imagens"
                                                        name="fabricante_ativo_#{fabricane.flagAtiva}.png"
                                                        style="borde:0" />
                                                <f:setPropertyActionListener target="#{fabricanteBean.fabricante}"
                                                        value="#{fabricane}" />
                                        </h:commandLink>
                                </h:column>
                                <h:column>
                                        <f:facet name="header">Nome</f:facet>
                        #{fabricane.nome}
                        </h:column>

                                <h:column>
                                        <f:facet name="header">CNPJ</f:facet>
                        #{fabricane.CNPJ}
                        </h:column>


                                <h:column>
                                        <f:facet name="header">Insc Estadual</f:facet>
                        #{fabricane.inscricaoEstadual}
                        </h:column>

                               

                                

                                

                                <h:column>
                                        <f:facet name="header">Ações</f:facet>
                                        <h:commandLink action="#{fabricanteBean.excluir}"
                                                onclick="if (!confirm('Deseja realmente excluir o fabricante #{fabricane.nome}?')) return false;">
                                                <h:graphicImage library="imagens" name="remove.png" />
                                                <f:setPropertyActionListener target="#{fabricanteBean.fabricante}"
                                                        value="#{fabricane}" />
                                        </h:commandLink>
                                </h:column>
                                <h:column>
                                        <h:commandLink action="#{fabricanteBean.editar}" value="">
                                                <h:graphicImage library="imagens" name="edita.jpg" style="borde:0" />
                                                <f:setPropertyActionListener target="#{fabricanteBean.fabricante}"
                                                        value="#{fabricane}" />
                                        </h:commandLink>
                                </h:column>
                        </h:dataTable>
                </h:form>

        </ui:define>
</ui:composition>

</html>